/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.system.mapper;


import com.koron.system.domain.OperationLog;
import org.apache.ibatis.annotations.Param;
import org.koron.ebs.mybatis.EnvSource;

import java.util.Date;
import java.util.List;


public interface OperationLogMapper {

    /**
     * whether the table exists or not
     * @param tableName
     * @return
     */
    Integer existTable(@Param("tableName") String tableName);


    /**
     * create the specific table
     * @param tableName
     * @return
     */
    Integer createTable(@Param("tableName") String tableName);


    /**
     * insert operationLog
     * @param tableName
     * @param operationLog
     * @return
     */
    Integer insert(@Param("tableName") String tableName, @Param("operationLog") OperationLog operationLog);

    /**
     * delete operation log in batch
     * @param tableName
     * @param idList
     * @return
     */
    Integer batchDetele(@Param("tableName") String tableName, @Param("idList") List<String> idList);

    /**
     * query the one whose id is the given
     * @param tableName
     * @param id
     * @return
     */
    OperationLog queryOne(@Param("tableName") String tableName, @Param("id") String id);


    /**
     * fetch all operation logs in the given condition
     * @param tableName
     * @param businessManipulation
     * @param operatorName
     * @param beginTime
     * @param endTime
     * @param start
     * @param rows
     * @return
     */
    List<OperationLog> queryByCondition(@Param("tableName") String tableName, @Param("businessManipulation") Integer businessManipulation,
                                        @Param("operatorName") String operatorName,  @Param("beginTime") Date beginTime,
                                        @Param("endTime") Date endTime, @Param("start") Integer start, @Param("rows") Integer rows,
                                        @Param("orgName") String orgName,@Param("businessModule")String businessModule);


    /**
     * the number of operation log complying with the condition
     * @param tableName
     * @param businessManipulation
     * @param operatorName
     * @param beginTime
     * @param endTime
     * @return
     */
    Integer countByCondition(@Param("tableName") String tableName, @Param("businessManipulation") Integer businessManipulation,
                             @Param("operatorName") String operatorName,  @Param("beginTime") Date beginTime,
                             @Param("endTime") Date endTime,@Param("orgName") String orgName,
                             @Param("businessModule") String businessModule);


    /**
     * fetch all operation logs from both tables in the given condition
     * @param tableName
     * @param nextTableName
     * @param businessManipulation
     * @param operatorName
     * @param beginTime
     * @param endTime
     * @param start
     * @param rows
     * @return
     */
    List<OperationLog> combineByCondition(@Param("tableName") String tableName, @Param("nextTableName") String nextTableName,
                                          @Param("businessManipulation") Integer businessManipulation,
                                          @Param("operatorName") String operatorName,  @Param("beginTime") Date beginTime,
                                          @Param("endTime") Date endTime, @Param("start") Integer start, @Param("rows") Integer rows,
                                          @Param("orgName") String orgName,@Param("businessModule")String businessModule);


    /**
     * the number of operation log complying with the condition in both tables
     * @param tableName
     * @param nextTableName
     * @param businessManipulation
     * @param operatorName
     * @param beginTime
     * @param endTime
     * @return
     */
    Integer countCombination(@Param("tableName") String tableName, @Param("nextTableName") String nextTableName,
                             @Param("businessManipulation") Integer businessManipulation, @Param("operatorName") String operatorName,
                             @Param("beginTime") Date beginTime, @Param("endTime") Date endTime,
                             @Param("orgName") String orgName,@Param("businessModule")String businessModule);

}
